import { Inject, Provide } from "@midwayjs/core";
import { JwtService } from "@midwayjs/jwt";

/**
 * Jwt工具
 * 
 * @author jn
 */
@Provide()
export class JwtSign {

    @Inject()
    jwtService: JwtService;

    /**
     * 生成时间秘钥
     * @param token 值
     * @param key 秘钥
     * @param time 过期时间
     * @returns 
     */
    async sign(token: string, key: string, time: { expiresIn: string }) {
        return await this.jwtService.sign(token, key, time)
    }

    /**
     * 生成不过期秘钥
     * @param token 值
     * @param key 秘钥
     * @returns 
     */
    async alongSign(token: string, key: string) {
        return await this.jwtService.sign(token, key)
    }
}